7. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-11-23 04:31:20 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

7.1 Files compared

#LocationFileLast Modified
1/Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.6/app/code/Smartwave/Filterproducts/Block/WidgetProducts.php2023-07-04 05:14:24 +0000
2/Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.7/app/code/Smartwave/Filterproducts/Block/WidgetProducts.php2023-11-22 08:10:32 +0000

7.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged2552
Changed00
Inserted15
Removed00

7.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

7.4 Active regular expressions

No regular expressions were active.

7.5 Comparison detail

1 <?php 1 <?php
2  2 
3 namespace Smartwave\Filterproducts\Block\Widget; 3 namespace Smartwave\Filterproducts\Block\Widget;
4  4 
5 use Magento\Catalog\Api\CategoryRepositoryInterface; 5 use Magento\Catalog\Api\CategoryRepositoryInterface;
6  6 
7  7 
8 class Products extends \Magento\Catalog\Block\Product\ListProduct implements \Magento\Widget\Block\BlockInterface { 8 class Products extends \Magento\Catalog\Block\Product\ListProduct implements \Magento\Widget\Block\BlockInterface {
9  9 
10     protected $_collection; 10     protected $_collection;
11  11 
12     protected $categoryRepository; 12     protected $categoryRepository;
13  13 
14     protected $_resource; 14     protected $_resource;
15  15 
16     protected $_pager; 16     protected $_pager;
17  17 
18     private $serializer; 18     private $serializer;
19  19 
20     const DISPLAY_TYPE_PRODUCTS = 'latest_products'; 20     const DISPLAY_TYPE_PRODUCTS = 'latest_products';
21  21 
22     const DEFAULT_SHOW_PAGER = false; 22     const DEFAULT_SHOW_PAGER = false;
23  23 
24     const DEFAULT_PRODUCTS_PER_PAGE = 5; 24     const DEFAULT_PRODUCTS_PER_PAGE = 5;
25  25 
26     const PAGE_VAR_NAME = 'np'; 26     const PAGE_VAR_NAME = 'np';
27  27 
28     public function __construct( 28     public function __construct(
29         \Magento\Catalog\Block\Product\Context $context, 29         \Magento\Catalog\Block\Product\Context $context,
30         \Magento\Framework\Data\Helper\PostHelper $postDataHelper, 30         \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
31         \Magento\Catalog\Model\Layer\Resolver $layerResolver, 31         \Magento\Catalog\Model\Layer\Resolver $layerResolver,
32         CategoryRepositoryInterface $categoryRepository, 32         CategoryRepositoryInterface $categoryRepository,
33         \Magento\Framework\Url\Helper\Data $urlHelper, 33         \Magento\Framework\Url\Helper\Data $urlHelper,
34         \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, 34         \Magento\Catalog\Model\ResourceModel\Product\Collection $collection,
35         \Magento\Framework\App\ResourceConnection $resource, 35         \Magento\Framework\App\ResourceConnection $resource,
36         array $data = [], 36         array $data = [],
37         \Magento\Framework\Serialize\Serializer\Json $serializer = null 37         \Magento\Framework\Serialize\Serializer\Json $serializer = null
38     ) { 38     ) {
39         $this->categoryRepository = $categoryRepository; 39         $this->categoryRepository = $categoryRepository;
40         $this->_collection = $collection; 40         $this->_collection = $collection;
41         $this->_resource = $resource; 41         $this->_resource = $resource;
42  42 
43         parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); 43         parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
44  44 
45         $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() 45         $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
46             ->get(\Magento\Framework\Serialize\Serializer\Json::class); 46             ->get(\Magento\Framework\Serialize\Serializer\Json::class);
47     } 47     }
48  48 
49     protected function _beforeToHtml() 49     protected function _beforeToHtml()
50     { 50     {
51         $this->setProductCollection($this->createCollection()); 51         $this->setProductCollection($this->createCollection());
52         return parent::_beforeToHtml(); 52         return parent::_beforeToHtml();
53     } 53     }
54  54 
55     public function createCollection() 55     public function createCollection()
56     { 56     {
57       $category_id = ''; 57       $category_id = '';
58       if($this->getData('category_ids')!=''){ 58       if($this->getData('category_ids')!=''){
59         if(explode('/', $this->getData('category_ids'))[0] == 'category'){ 59         if(explode('/', $this->getData('category_ids'))[0] == 'category'){
60           $category_id = explode('/', $this->getData('category_ids'))[1]; 60           $category_id = explode('/', $this->getData('category_ids'))[1];
61         }else{ 61         }else{
62           $category_id = $this->getData('category_ids'); 62           $category_id = $this->getData('category_ids');
63         } 63         }
64       } 64       }
65       $collection = clone $this->_collection; 65       $collection = clone $this->_collection;
66       $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP); 66       $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP);
67  67 
68       if(!$category_id) { 68       if(!$category_id) {
69           $category_id = $this->_storeManager->getStore()->getRootCategoryId(); 69           $category_id = $this->_storeManager->getStore()->getRootCategoryId();
70       } 70       }
71       $category = $this->categoryRepository->get($category_id); 71       $category = $this->categoryRepository->get($category_id);
72  72 
73       if ($this->getData('store_id') !== null) { 73       if ($this->getData('store_id') !== null) {
74           $collection->setStoreId($this->getData('store_id')); 74           $collection->setStoreId($this->getData('store_id'));
75       } 75       }
76  76 
77       $collection->addMinimalPrice() 77       $collection->addMinimalPrice()
78           ->addFinalPrice() 78           ->addFinalPrice()
79           ->addTaxPercents() 79           ->addTaxPercents()
80           ->addAttributeToSelect('name') 80           ->addAttributeToSelect('name')
81           ->addAttributeToSelect('image') 81           ->addAttributeToSelect('image')
82           ->addAttributeToSelect('small_image') 82           ->addAttributeToSelect('small_image')
83           ->addAttributeToSelect('thumbnail') 83           ->addAttributeToSelect('thumbnail')
84           ->addAttributeToSelect('special_from_date') 84           ->addAttributeToSelect('special_from_date')
85           ->addAttributeToSelect('special_to_date') 85           ->addAttributeToSelect('special_to_date')
86           ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) 86           ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())
87           ->addUrlRewrite() 87           ->addUrlRewrite()
88           ->addStoreFilter(); 88           ->addStoreFilter();
89  89 
90       if(isset($category) && $category) 90       if(isset($category) && $category)
91       { 91       {
92         $collection->addCategoryFilter($category); 92         $collection->addCategoryFilter($category);
93       } 93       }
94       switch ($this->getDisplayType()) 94       switch ($this->getDisplayType())
95       { 95       {
96           case 'new_products': 96           case 'new_products':
97               $collection->addAttributeToFilter( 97               $collection->addAttributeToFilter(
98                     'news_from_date', 98                     'news_from_date',
99                     ['date' => true, 'to' => $this->getEndOfDayDate()], 99                     ['date' => true, 'to' => $this->getEndOfDayDate()],
100                     'left') 100                     'left')
101                 ->addAttributeToFilter( 101                 ->addAttributeToFilter(
102                     'news_to_date', 102                     'news_to_date',
103                     [ 103                     [
104                         'or' => [ 104                         'or' => [
105                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()], 105                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()],
106                             1 => ['is' => new \Zend_Db_Expr('null')], 106                             1 => ['is' => new \Zend_Db_Expr('null')],
107                         ] 107                         ]
108                     ], 108                     ],
109                     'left') 109                     'left')
110                 ->addAttributeToSort( 110                 ->addAttributeToSort(
111                     'news_from_date', 111                     'news_from_date',
112                     'desc'); 112                     'desc');
113               break; 113               break;
114           case 'featured_products': 114           case 'featured_products':
115               $collection->addAttributeToFilter('sw_featured', 1, 'left'); 115               $collection->addAttributeToFilter('sw_featured', 1, 'left');
116               break; 116               break;
117           case 'bestseller_products': 117           case 'bestseller_products':
118               $collection->getSelect() 118               $collection->getSelect()
119                   ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty']) 119                   ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty'])
120                   ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state']) 120                   ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state'])
121                   ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL") 121                   ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL")
122                   ->group('soi.product_id') 122                   ->group('soi.product_id')
123                   ->order('ordered_qty DESC'); 123                   ->order('ordered_qty DESC');
    124               /*$collection->getSelect()
    125                 ->join(['bestsellers' => $collection->getTable('sales_bestsellers_aggregated_yearly')],
    126                     'e.entity_id = bestsellers.product_id AND bestsellers.store_id = '.$this->getData('store_id'),
    127                     ['qty_ordered','rating_pos'])
    128                 ->order('rating_pos');*/
124               break; 129               break;
125           case 'sale_products': 130           case 'sale_products':
126               $collection->addAttributeToFilter('special_price', ['neq' => '']) 131               $collection->addAttributeToFilter('special_price', ['neq' => ''])
127               ->addAttributeToFilter( 132               ->addAttributeToFilter(
128                     'special_from_date', 133                     'special_from_date',
129                     ['date' => true, 'to' => $this->getEndOfDayDate()], 134                     ['date' => true, 'to' => $this->getEndOfDayDate()],
130                     'left') 135                     'left')
131                 ->addAttributeToFilter( 136                 ->addAttributeToFilter(
132                     'special_to_date', 137                     'special_to_date',
133                     [ 138                     [
134                         'or' => [ 139                         'or' => [
135                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()], 140                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()],
136                             1 => ['is' => new \Zend_Db_Expr('null')], 141                             1 => ['is' => new \Zend_Db_Expr('null')],
137                         ] 142                         ]
138                     ], 143                     ],
139                     'left') 144                     'left')
140                 ->addAttributeToSort( 145                 ->addAttributeToSort(
141                     'news_from_date', 146                     'news_from_date',
142                     'desc'); 147                     'desc');
143               break; 148               break;
144           case 'deal_products': 149           case 'deal_products':
145               $collection->getSelect() 150               $collection->getSelect()
146                   ->joinLeft(['dai' => $collection->getTable('sw_dailydeals_dailydeal')], 'dai.sw_product_sku = e.sku') 151                   ->joinLeft(['dai' => $collection->getTable('sw_dailydeals_dailydeal')], 'dai.sw_product_sku = e.sku')
147                   ->where('dai.sw_deal_enable=1') 152                   ->where('dai.sw_deal_enable=1')
148                   ->where( 153                   ->where(
149                       'dai.sw_date_from <= "'.$this->getDayDate().'" or dai.sw_date_from IS NULL' 154                       'dai.sw_date_from <= "'.$this->getDayDate().'" or dai.sw_date_from IS NULL'
150                   )->where( 155                   )->where(
151                       'dai.sw_date_to >= "'.$this->getDayDate().'" or dai.sw_date_to IS NULL' 156                       'dai.sw_date_to >= "'.$this->getDayDate().'" or dai.sw_date_to IS NULL'
152                   ); 157                   );
153               break; 158               break;
154           default: 159           default:
155               $collection->addAttributeToSort('created_at','desc'); 160               $collection->addAttributeToSort('created_at','desc');
156               break; 161               break;
157       } 162       }
158  163 
159       $collection->setPageSize($this->getPageSize()) 164       $collection->setPageSize($this->getPageSize())
160                  ->setCurPage($this->getCurrentPage()); 165                  ->setCurPage($this->getCurrentPage());
161  166 
162       if($this->getDisplayType() == 'featured_products') { 167       if($this->getDisplayType() == 'featured_products') {
163         $collection->getSelect()->order('rand()'); 168         $collection->getSelect()->order('rand()');
164       } 169       }
165  170 
166       return $collection; 171       return $collection;
167     } 172     }
168  173 
169     public function getCurrentPage() 174     public function getCurrentPage()
170     { 175     {
171         return abs((int)$this->getRequest()->getParam($this->getData('page_var_name'))); 176         return abs((int)$this->getRequest()->getParam($this->getData('page_var_name')));
172     } 177     }
173  178 
174     public function getCacheKeyInfo() 179     public function getCacheKeyInfo()
175     { 180     {
176         return array_merge( 181         return array_merge(
177             parent::getCacheKeyInfo(), 182             parent::getCacheKeyInfo(),
178             [ 183             [
179                 $this->getDisplayType(), 184                 $this->getDisplayType(),
180                 $this->_storeManager->getStore()->getId(), 185                 $this->_storeManager->getStore()->getId(),
181                 $this->getProductsPerPage(), 186                 $this->getProductsPerPage(),
182                 (int) $this->getRequest()->getParam($this->getData('page_var_name'), 1), 187                 (int) $this->getRequest()->getParam($this->getData('page_var_name'), 1),
183                 $this->serializer->serialize($this->getRequest()->getParams()) 188                 $this->serializer->serialize($this->getRequest()->getParams())
184             ] 189             ]
185         ); 190         );
186     } 191     }
187  192 
188     public function getDisplayType() 193     public function getDisplayType()
189     { 194     {
190         if (!$this->hasData('display_type')) { 195         if (!$this->hasData('display_type')) {
191             $this->setData('display_type', self::DISPLAY_TYPE_PRODUCTS); 196             $this->setData('display_type', self::DISPLAY_TYPE_PRODUCTS);
192         } 197         }
193         return $this->getData('display_type'); 198         return $this->getData('display_type');
194     } 199     }
195  200 
196     public function getProductsCount() 201     public function getProductsCount()
197     { 202     {
198         if (!$this->hasData('product_count')) { 203         if (!$this->hasData('product_count')) {
199             return parent::getProductsCount(); 204             return parent::getProductsCount();
200         } 205         }
201         return $this->getData('product_count'); 206         return $this->getData('product_count');
202     } 207     }
203  208 
204     public function getProductsPerPage() 209     public function getProductsPerPage()
205     { 210     {
206         if (!$this->hasData('products_per_page')) { 211         if (!$this->hasData('products_per_page')) {
207             $this->setData('products_per_page', self::DEFAULT_PRODUCTS_PER_PAGE); 212             $this->setData('products_per_page', self::DEFAULT_PRODUCTS_PER_PAGE);
208         } 213         }
209         return $this->getData('products_per_page'); 214         return $this->getData('products_per_page');
210     } 215     }
211  216 
212     public function showPager() 217     public function showPager()
213     { 218     {
214         if (!$this->hasData('show_pager')) 219         if (!$this->hasData('show_pager'))
215         { 220         {
216             $this->setData('show_pager', self::DEFAULT_SHOW_PAGER); 221             $this->setData('show_pager', self::DEFAULT_SHOW_PAGER);
217         } 222         }
218         return (bool)$this->getData('show_pager'); 223         return (bool)$this->getData('show_pager');
219     } 224     }
220  225 
221     protected function getPageSize() 226     protected function getPageSize()
222     { 227     {
223         return $this->showPager() ? $this->getProductsPerPage() : $this->getProductsCount(); 228         return $this->showPager() ? $this->getProductsPerPage() : $this->getProductsCount();
224     } 229     }
225  230 
226     public function getPagerHtml() 231     public function getPagerHtml()
227     { 232     {
228         if ($this->showPager()) { 233         if ($this->showPager()) {
229             if (!$this->_pager) { 234             if (!$this->_pager) {
230                 $this->_pager = $this->getLayout()->createBlock( 235                 $this->_pager = $this->getLayout()->createBlock(
231                     \Magento\Catalog\Block\Product\Widget\Html\Pager::class, 236                     \Magento\Catalog\Block\Product\Widget\Html\Pager::class,
232                     $this->getWidgetPagerBlockName() 237                     $this->getWidgetPagerBlockName()
233                 ); 238                 );
234  239 
235                 $this->_pager->setUseContainer(true) 240                 $this->_pager->setUseContainer(true)
236                     ->setShowAmounts(true) 241                     ->setShowAmounts(true)
237                     ->setShowPerPage(false) 242                     ->setShowPerPage(false)
238                     ->setPageVarName($this->getData('page_var_name')) 243                     ->setPageVarName($this->getData('page_var_name'))
239                     ->setLimit($this->getProductsPerPage()) 244                     ->setLimit($this->getProductsPerPage())
240                     ->setTotalLimit($this->getProductsCount()) 245                     ->setTotalLimit($this->getProductsCount())
241                     ->setCollection($this->getProductCollection()); 246                     ->setCollection($this->getProductCollection());
242             } 247             }
243             if ($this->_pager instanceof \Magento\Framework\View\Element\AbstractBlock) { 248             if ($this->_pager instanceof \Magento\Framework\View\Element\AbstractBlock) {
244                 return $this->_pager->toHtml(); 249                 return $this->_pager->toHtml();
245             } 250             }
246         } 251         }
247         return ''; 252         return '';
248     } 253     }
249  254 
250     private function getWidgetPagerBlockName() 255     private function getWidgetPagerBlockName()
251     { 256     {
252         $pageName = $this->getData('page_var_name'); 257         $pageName = $this->getData('page_var_name');
253         $pagerBlockName = 'widget.porto.filter.products.pager'; 258         $pagerBlockName = 'widget.porto.filter.products.pager';
254  259 
255         if (!$pageName) { 260         if (!$pageName) {
256             return $pagerBlockName; 261             return $pagerBlockName;
257         } 262         }
258  263 
259         return $pagerBlockName . '.' . $pageName; 264         return $pagerBlockName . '.' . $pageName;
260     } 265     }
261  266 
262     public function getDayDate() 267     public function getDayDate()
263     { 268     {
264         return $this->_localeDate->date()->format('Y-m-d H:i:s'); 269         return $this->_localeDate->date()->format('Y-m-d H:i:s');
265     } 270     }
266  271 
267     public function getStartOfDayDate() 272     public function getStartOfDayDate()
268     { 273     {
269         return $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s'); 274         return $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s');
270     } 275     }
271  276 
272     public function getEndOfDayDate() 277     public function getEndOfDayDate()
273     { 278     {
274         return $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s'); 279         return $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s');
275     } 280     }
276 } 281 }